<template>
<view>
	<view class="top">
		<view @click="select(1)" class="header_select border_right" :class="type == 1 ? 'border-bottom' : ''">充值</view>
		<view @click="select(2)" class="header_select border_right" :class="type == 2 ? 'border-bottom' : ''">购卡</view>
		<view @click="select(3)" class="header_select border_right" :class="type == 3 ? 'border-bottom' : ''">消费</view>
	</view>
	<view class="table">
		<table border="0" width="95%" cellspacing="0" cellpadding="0">
			<tr v-if="type == 1">
				<td>充值金额</td>
				<td>代金券</td>
				<td>支付金额</td>
			</tr>
			<tr v-if="type == 2">
				<td>项目名称</td>
				<td>账户抵扣</td>
				<td>代金券</td>
				<td>支付金额</td>
			</tr>
			<tr v-if="type == 3">
				<td>商品名称</td>
				<td>账户抵扣</td>
				<td>代金券</td>
				<td>支付金额</td>
			</tr>
			<tr v-for="(item,index) in list" :key="index" v-if="type == 1">
				<td>{{item.pay_money}}</td>
				<td>{{item.give_money}}</td>
				<td>{{item.pay_money}}</td>
			</tr>
			<tr v-for="(item,index) in list" :key="index" v-if="type == 2 || type == 3">
				<td>{{item.name}}</td>
				<td>{{item.offset_money}}</td>
				<td>{{item.give_money}}</td>
				<td>{{item.pay_money}}</td>
			</tr>
		</table>
	</view>
</view>
</template>
<script>
import request from '@/util/request.js'
export default {
	data() {
		return {
			//oaRole 1:店长2:员工3:商户
			type:1,
			list:[],
			page:1,
			pageShow:true,
			member_id:0
		}
	},
	onLoad:function(e){
		this.member_id = e.id
		uni.showLoading({
		    title: '加载中'  
		});
		this.getList();
	},
	methods: {
		getList:function(){
			var data = {
				type:this.type,
				page:this.page,
				member_id:this.member_id
			}
			var that = this
			request({
				url: 'manage/center/list',
				method: 'get',
				data:data,
				success: (res) => {
					uni.hideLoading();
					if(res.data.data.last_page <= that.page){
						that.pageShow = false
					}
					if(that.page == 1){
						that.list = res.data.data.data
					}else{
						var list = that.list
						that.list = list.concat(res.data.data.data)
					}
				},
			})
		},
		select:function(key){
			this.type = key
			this.page = 1
			this.pageShow = true
			uni.showLoading()
			this.getList();
		},
		onReachBottom: function(){
			if(this.pageShow){
				 //当前不是最后一页可加载
				 this.page = this.page + 1
				 uni.showLoading()
				 this.getList();
			}
		},
		jump:function(url,id,pay){
			uni.navigateTo({
			  url:url+'?id='+id+'&type='+this.type+'&pay='+pay
			})
		}
	},
}
</script>
<style>
.header{
    width:100%;
    height:80rpx;
    line-height: 80rpx;
    text-align: center;
    background:#00b300;
    color:#fff;
}
.top{
    width:100%;
    height:80rpx;
    line-height: 80rpx;
    display: flex;
    flex-direction: row;
    align-items: center;
}
.header_select{
    width:33%;
    text-align: center;
    border-bottom:1px solid #b3b3b3;
}
.border_right{
    border-right:1px solid #b3b3b3;
}
.border-bottom{
    border-bottom: 3px solid red;
}
.table{
	width:100%;
	padding:10rpx 20rpx 120rpx 20rpx;
}
table{
	margin-top:30rpx;
}
td{
	border:1rpx solid #C8C7CC;
	text-align: center;
	height:70rpx;
	line-height:70rpx;
}
td img{
	width:30rpx;
	height:30rpx;
}
</style>